package com.invest.vo;

import com.invest.config.AppProperties;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;

/**
 * <p>注释</p>
 *
 * @author yuyizhao
 * @version v0.1 2016/3/15 Exp
 */
public class StaticFileVO  extends  AbstractFileVO{

    @NotNull(message = "文件名不能为空")
    private String name;

    @NotNull(message = "文件不能为空")
    private MultipartFile file;

    private String fileDiskPath;

    private String fileUriPath;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public MultipartFile getFile() {
        return file;
    }

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public void build(String crpId, AppProperties fileProperties){

        String fileFullName =  randomFileName(AbstractFileVO.FILE_DEFAULT_PREFIX,file.getOriginalFilename());
        fileDiskPath = getDiskPath(crpId,fileFullName,fileProperties);
        fileUriPath = getUriPath(crpId,fileFullName,fileProperties);

    }

    public String getFileDiskPath() {
        return fileDiskPath;
    }

    public void setFileDiskPath(String fileDiskPath) {
        this.fileDiskPath = fileDiskPath;
    }

    public String getFileUriPath() {
        return fileUriPath;
    }

    public void setFileUriPath(String fileUriPath) {
        this.fileUriPath = fileUriPath;
    }
}
